/*
 * @Description  : 公共数据
 * @Author       : zhao
 * @Date         : 2022-07-26 11:44:30
 * @LastEditors  : zhao
 * @LastEditTime : 2023-02-04 10:41:42
 */

import { useUserInfo } from '/@/stores/userInfo'
interface Category {
    value: string;
    key: string;
}
interface zdata {
    Category: Array<Category>;
    chartColor: Array<string>;
    Preview: any;
    rules: any,
    mineral: any,
    workDegree: any
}
let data = <zdata>{}
data.Category = [
    { value: "区域地质调查", key: "区域地质调查" },
    { value: "矿产勘查", key: "矿产勘查" },
    { value: "水工环地质勘查", key: "水工环地质勘查" },
    { value: "物化遥勘查", key: "物化遥勘查" },
    { value: "油气地质", key: "油气地质" },
    { value: "海洋地质", key: "海洋地质" },
    { value: "地质科学研究", key: "地质科学研究" },
    { value: "技术方法", key: "技术方法" },
    { value: "其他", key: "其他" },
]
data.chartColor = ['#51A3FC', '#36C78B', '#FEC279', '#968AF5', '#E790E8', '#7FFFD4', '#abc88b', '#5F9EA0', '#6495ED', '#7FFFD4', '#FF8C00', '#00CED1', '#F0E68C'];

//预览 
data.Preview = function (data: any) {
    let file = data.res
    // // 创建blob对象，解析流数据
    const blob = new Blob([data.res], {
        // 设置返回的文件类型
        // type: 'application/pdf;charset=UTF-8' 表示下载文档为pdf，如果是word则设置为msword，excel为excel
        // type: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
        type: data.type
    })
    let url = null
    let win = window

    if (window.URL !== undefined) { // mozilla(firefox)
        try {
            url = window.URL.createObjectURL(file)

        } catch (error) {
            // console.log(error)
        }
    }

    return url

    // var r = window.open();
    // r.document.body.innerHTML = href;


}
data.rules = {
    userName: [
        { required: true, message: "请输入账号名称", trigger: "blur" },
        {
            pattern: /^[a-zA-Z]{1}[a-zA-Z0-9_]{5,14}$/,
            message: "6-15个字符,可使用字母、数字、下划线。需以字母开头(账号不区分大小写)",
            trigger: "blur",
        },
    ],
    password: [
        { required: true, message: "请输入密码", trigger: "blur" },
        {
            pattern: /^.{6,28}$/,
            message: "密码长度为6-28个字符",
            trigger: "blur",
        },
    ],

    phone: [
        { required: true, message: "请输入手机号", trigger: "blur" },
        {
            pattern: /^(1[3-9])\d{9}$/,
            message: "手机号不正确",
            trigger: "blur",
        },
    ],
    realName: [{ required: true, message: "请输入真实姓名", trigger: "blur" }],
}

const useUserInfos = useUserInfo()
data.mineral = async () => {
    const mineralData = await useUserInfos.GetArchiveList()

    try {
        return mineralData.data
    } catch {
        return []
    }
}

data.workDegree = [

    { value: "不限", IsSelect: false, key: "" },
    { value: "小于1:100万", IsSelect: true, key: "小于1:100万" },
    { value: "1:100万", IsSelect: true, key: "1:1000000" },
    { value: "1:50万", IsSelect: true, key: "1:500000" },
    { value: "1:25万", IsSelect: true, key: "1:250000" },
    { value: "1:20万", IsSelect: true, key: "1:200000" },
    { value: "1:10万", IsSelect: true, key: "1:100000" },
    { value: "1:5万", IsSelect: true, key: "1:50000" },
    { value: "1:2.5万", IsSelect: true, key: "1:25000" },
    { value: "1:1万", IsSelect: true, key: "1:10000" },
    { value: "大于1:1万", IsSelect: true, key: "大于1:1万" },

    { value: "预查", IsSelect: true, key: "预查" },
    { value: "普查", IsSelect: true, key: "普查" },
    { value: "详查", IsSelect: true, key: "详查" },
    { value: "勘探", IsSelect: true, key: "勘探" },
    { value: "开发勘探", IsSelect: true, key: "开发勘探" },
]
export default data